package JavaSEAdvance.Lanlords;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author Xiao
 * @date 2021/7/28
 */
public class LandlordsDemo {
    /**
     * 模拟斗地主：
     * 通过程序实现斗地主过程中的洗牌、发牌和看牌。  ♠   ♥   ♦   ♣    King    Queen
     */
    public static void main(String[] args) {
        /*ArrayList<String> list = new ArrayList<>(
                List.of("2♠", "3♠", "4♠", "5♠", "6♠", "7♠", "8♠", "9♠", "10♠", "J♠", "Q♠", "K♠", "A♠",
                        "2♥", "3♥", "4♥", "5♥", "6♥", "7♥", "8♥", "9♥", "10♥", "J♥", "Q♥", "K♥", "A♥",
                        "2♦", "3♦", "4♦", "5♦", "6♦", "7♦", "8♦", "9♦", "10♦", "J♦", "Q♦", "K♦", "A♦",
                        "2♣", "3♣", "4♣", "5♣", "6♣", "7♣", "8♣", "9♣", "10♣", "J♣", "Q♣", "K♣", "A♣",
                        "King", "Queen"));*/
        ArrayList<String> list = new ArrayList<>(List.of("King", "Queen"));
        String[] color = {"♠", "♥", "♦", "♣"};
        String[] number = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
        for (String s : color) {
            for (String s1 : number) {
                list.add(s1 + s);
            }
        }
        Collections.shuffle(list);
        ArrayList<String> list1 = new ArrayList<>();
        ArrayList<String> list2 = new ArrayList<>();
        ArrayList<String> list3 = new ArrayList<>();
        ArrayList<String> list4 = new ArrayList<>();
        for (int i = 0; i < list.size() - 6; i += 3) {
            list1.add(list.get(i));
            list2.add(list.get(i + 1));
            list3.add(list.get(i + 2));
        }
        for (int i = 0; i < 3; i++) {
            int index = list.size() - 1 - i;
            list4.add(list.get(index));
        }
        Collections.sort(list1);
        Collections.sort(list2);
        Collections.sort(list3);
        System.out.println("阿良的牌：" + list1);
        System.out.println("左右的牌：" + list2);
        System.out.println("平安的牌：" + list3);
        System.out.println("-----------");
        System.out.println("底牌：" + list4);
    }
}
